package com.crimsec.utils.snmp.model;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * $Id$ представляет метаданные базы MIB
 */
@Entity
@Table(name = "mibdb")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Mibdb.findAll", query = "SELECT m FROM Mibdb m"),
    @NamedQuery(name = "Mibdb.findById", query = "SELECT m FROM Mibdb m WHERE m.id = :id"),
    @NamedQuery(name = "Mibdb.findByName", query = "SELECT m FROM Mibdb m WHERE m.name = :name")})
public class Mibdb extends AbstractEntity implements Serializable {

    private static final long serialVersionUID = 1L;
    //
    @Id
    @Basic(optional = false)
    @Column(name = "id")
    private Short id;
    //имя базы MIB (i.e 'SNMPv2-SMI')
    @Basic(optional = false)
    @Column(name = "name")
    private String name;

    public Mibdb() {
    }

    public Mibdb(Short id) {
        this.id = id;
    }

    public Mibdb(Short id, String name) {
        this.id = id;
        this.name = name;
    }

    @XmlAttribute
    public Short getId() {
        return id;
    }

    public void setId(Short id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Mibdb)) {
            return false;
        }
        Mibdb other = (Mibdb) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.crimsec.utils.snmp.model.Mibdb[ id=" + id + " ]";
    }
}
